#!/usr/bin/env python
# -*- coding: utf8 -*-
# title       :
# description :
# author      :'ShenMeng'


def main():
    import maya.cmds as cmds
    import maya.mel as mel
    import os
    import sys
    try:
        from batchmanager.core.verbatchmanager import Tasker
        scene_file = cmds.file(q=1, sn=1)
        root_path = os.path.dirname(scene_file).replace('\\', '/')
        scene_name = os.path.basename(scene_file)
        tasker = Tasker('export', root_path, 'cam')
        ctime = tasker.getTime()

        try:
            #source_file = os.path.join(os.path.dirname(__file__), 'exporttoue4.mel').replace('\\', '/')
            #mel.eval('source "%s";' % source_file)
            #mel.eval("exprotUE4ActivateFile();")
            from exportmanager.core import ExportManagerCam
            em = ExportManagerCam(config='deformationcar.yml')
            em.main()
        except Exception, e:
            data = {scene_name:{"user":tasker.id, "time":ctime, "info":str(e)}}
            tasker.loggle(data, 'error')
        else:
            data = {scene_name:{"user":tasker.id, "time":ctime}}
            tasker.loggle(data, 'ok')
    except Exception, e:
        print e
    finally:
        cmds.scriptJob(ie="cmds.quit(f=1)")

